home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
526-550
/
disk_534
/
term
/
source.lzh
/
EmulationPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-17
|
12KB
|
402 lines
/* $Revision Header * Header built automatically - do not edit! *************
*
* (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
*
* Name .....: EmulationPanel.c
* Created ..: Thursday 21-Mar-91 20:19
* Revision .: 0
*
* Date Author Comment
* ========= ======== ====================
* 21-Mar-91 Olsen Created this file!
*
* $Revision Header ********************************************************/
#include "TermGlobal.h"
enum { GAD_SMOOTHSCROLL,GAD_WRAPCHARS,GAD_WRAPCURSOR,GAD_INSERTMODE,GAD_NEWLINE,
GAD_NUMKEYPAD,GAD_CURSORKEYS,GAD_FONTSCALE,GAD_USE,GAD_CANCEL };
#define WIDTH 367
#define HEIGHT 128
STATIC STRPTR ControlMode[3] =
{
(STRPTR)"Standard Mode",
(STRPTR)"Application Mode",
NULL
};
STATIC STRPTR ScaleFontText[6] =
{
(STRPTR)"Normal Scale",
(STRPTR)"Double Height (Top)",
(STRPTR)"Double Height (Bottom)",
(STRPTR)"Double Width",
(STRPTR)"Half Width",
NULL
};
enum { MEN_SMOOTHSCROLL,MEN_WRAPCHARS,MEN_WRAPCURSOR,MEN_INSERTMODE,MEN_NEWLINE,
MEN_NUMKEYPAD,MEN_CURSORKEYS,MEN_FONTSCALE,MEN_USE,MEN_CANCEL,MEN_QUITPANEL };
STATIC struct NewMenu EmulationMenu[] =
{
{ NM_TITLE, "Project", 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Smooth Scrolling", "S", 0, 0, (APTR)MEN_SMOOTHSCROLL},
{ NM_ITEM, "Wrap Characters", "C", 0, 0, (APTR)MEN_WRAPCHARS},
{ NM_ITEM, "Wrap Cursor Movements", "M", 0, 0, (APTR)MEN_WRAPCURSOR},
{ NM_ITEM, "Insert Mode", "I", 0, 0, (APTR)MEN_INSERTMODE},
{ NM_ITEM, "New-Line Mode", "L", 0, 0, (APTR)MEN_NEWLINE},
{ NM_ITEM, "Numeric Keypad Mode", "N", 0, 0, (APTR)MEN_NUMKEYPAD},
{ NM_ITEM, "Cursor Keys Mode", "K", 0, 0, (APTR)MEN_CURSORKEYS},
{ NM_ITEM, "Font Scale", "F", 0, 0, (APTR)MEN_FONTSCALE},
{ NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Use", "U", 0, 0, (APTR)MEN_USE},
{ NM_ITEM, "Cancel", "C", 0, 0, (APTR)MEN_CANCEL},
{ NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Quit", "Q", 0, 0, (APTR)MEN_QUITPANEL},
{ NM_END, 0, 0 , 0, 0, (APTR)0}
};
STATIC struct Gadget *
CreateAllGadgets(struct Configuration *Config,struct Gadget *GadgetArray[],struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
if(Gadget = CreateContext(GadgetList))
{
NewGadget . ng_Width = 204;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "_Smooth Scrolling";
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_VisualInfo = VisualInfo;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = NG_HIGHLABEL;
NewGadget . ng_LeftEdge = (strlen(NewGadget . ng_GadgetText) + 2) * 8 + 1;
NewGadget . ng_TopEdge = 1 + TopEdge;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> JumpScroll ^ TRUE,
TAG_DONE);
NewGadget . ng_GadgetText = "Wrap _Characters";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> AutoWrap,
TAG_DONE);
NewGadget . ng_GadgetText = "Wrap Cursor _Moves";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> CursorWrap,
TAG_DONE);
NewGadget . ng_GadgetText = "_Insert Mode";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> InsertChar,
TAG_DONE);
NewGadget . ng_GadgetText = "New-_Line Mode";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> NewLine,
TAG_DONE);
NewGadget . ng_GadgetText = "_Numeric Keypad";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCY_Labels, ControlMode,
GTCY_Active, Config -> NumApp,
TAG_DONE);
NewGadget . ng_GadgetText = "Cursor _Keys";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCY_Labels, ControlMode,
GTCY_Active, Config -> CursorApp,
TAG_DONE);
NewGadget . ng_GadgetText = "_Font Scale";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCY_Labels, ScaleFontText,
GTCY_Active, Config -> FontScale,
TAG_DONE);
NewGadget . ng_Width = 52;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "_Use";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
NewGadget . ng_LeftEdge = 10;
NewGadget . ng_TopEdge = HEIGHT - 3 - NewGadget . ng_Height;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "_Cancel";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = WIDTH - 10 - NewGadget . ng_Width;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
}
return(Gadget);
}
VOID
EmulationPanel(struct Configuration *Config)
{
struct Window *PanelWindow;
struct Menu *PanelMenu;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_CANCEL + 1];
ClearCursor();
CopyMem(Config,&PrivateConfig,sizeof(struct Configuration));
if(CreateAllGadgets(Config,&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
{
if(PanelMenu = CreateMenus(EmulationMenu,
GTMN_FrontPen, 0,
TAG_DONE))
{
if(LayoutMenus(PanelMenu,VisualInfo,
GTMN_TextAttr,&DefaultFont,
TAG_DONE))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - WIDTH) >> 1,
WA_Top, (Screen -> Height - HEIGHT) >> 1,
WA_Width, WIDTH,
WA_Height, HEIGHT,
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Screen,
WA_IDCMP, IDCMP_GADGETDOWN | IDCMP_ACTIVEWINDOW | IDCMP_CLOSEWINDOW | SLIDERIDCMP | CHECKBOXIDCMP | LISTVIEWIDCMP | IDCMP_MENUPICK | IDCMP_RAWKEY,
WA_Title, "Emulation Preferences",
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG Class,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
SetMenuStrip(PanelWindow,PanelMenu);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
while(!Terminated)
{
WaitPort(PanelWindow -> UserPort);
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
Class = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
if(Class == IDCMP_MENUPICK)
{
struct MenuItem *MenuItem;
while(Code != MENUNULL)
{
MenuItem = ItemAddress(PanelMenu,Code);
switch((ULONG)MENU_USERDATA(MenuItem))
{
case MEN_QUITPANEL: Class = IDCMP_CLOSEWINDOW;
break;
case MEN_USE: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_USE];
break;
case MEN_CANCEL: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_CANCEL];
break;
case MEN_SMOOTHSCROLL: GT_SetGadgetAttrs(GadgetArray[GAD_SMOOTHSCROLL],PanelWindow,NULL,
GTCB_Checked,GadgetArray[GAD_SMOOTHSCROLL] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
TAG_DONE);
break;
case MEN_WRAPCHARS: GT_SetGadgetAttrs(GadgetArray[GAD_WRAPCHARS],PanelWindow,NULL,
GTCB_Checked,GadgetArray[GAD_WRAPCHARS] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
TAG_DONE);
break;
case MEN_WRAPCURSOR: GT_SetGadgetAttrs(GadgetArray[GAD_WRAPCURSOR],PanelWindow,NULL,
GTCB_Checked,GadgetArray[GAD_WRAPCURSOR] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
TAG_DONE);
break;
case MEN_NEWLINE: GT_SetGadgetAttrs(GadgetArray[GAD_NEWLINE],PanelWindow,NULL,
GTCB_Checked,GadgetArray[GAD_NEWLINE] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
TAG_DONE);
break;
case MEN_INSERTMODE: GT_SetGadgetAttrs(GadgetArray[GAD_INSERTMODE],PanelWindow,NULL,
GTCB_Checked,GadgetArray[GAD_INSERTMODE] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
TAG_DONE);
break;
case MEN_NUMKEYPAD: Config -> NumApp ^= TRUE;
GT_SetGadgetAttrs(GadgetArray[GAD_NUMKEYPAD],PanelWindow,NULL,
GTCY_Active,Config -> NumApp,
TAG_DONE);
break;
case MEN_CURSORKEYS: Config -> CursorApp ^= TRUE;
GT_SetGadgetAttrs(GadgetArray[GAD_CURSORKEYS],PanelWindow,NULL,
GTCY_Active,Config -> CursorApp,
TAG_DONE);
break;
case MEN_FONTSCALE: if(Config -> FontScale == SCALE_HALF)
Config -> FontScale = SCALE_NORMAL;
else
Config -> FontScale++;
GT_SetGadgetAttrs(GadgetArray[GAD_FONTSCALE],PanelWindow,NULL,
GTCY_Active,Config -> FontScale,
TAG_DONE);
break;
default: break;
}
Code = MenuItem -> NextSelect;
}
}
if(Class == IDCMP_CLOSEWINDOW)
Terminated = TRUE;
GadCheck: if(Class == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_USE: Terminated = TRUE;
Config -> JumpScroll = (GadgetArray[GAD_SMOOTHSCROLL] -> Flags & GFLG_SELECTED) ? FALSE : TRUE;
Config -> AutoWrap = GadgetArray[GAD_WRAPCHARS] -> Flags & GFLG_SELECTED;
Config -> CursorWrap = GadgetArray[GAD_WRAPCURSOR] -> Flags & GFLG_SELECTED;
Config -> InsertChar = GadgetArray[GAD_INSERTMODE] -> Flags & GFLG_SELECTED;
Config -> NewLine = GadgetArray[GAD_NEWLINE] -> Flags & GFLG_SELECTED;
break;
case GAD_CANCEL: Terminated = TRUE;
CopyMem(&PrivateConfig,Config,sizeof(struct Configuration));
break;
case GAD_NUMKEYPAD: Config -> NumApp = Code;
break;
case GAD_CURSORKEYS: Config -> CursorApp = Code;
break;
case GAD_FONTSCALE: Config -> FontScale = Code;
break;
default: break;
}
}
}
}
PanelWindow -> Flags |= WFLG_RMBTRAP;
ClearMenuStrip(PanelWindow);
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
}
FreeMenus(PanelMenu);
}
FreeGadgets(GadgetList);
}
if(PrivateConfig . FontScale == SCALE_HALF && Config -> FontScale != SCALE_HALF)
{
CursorX >>= 1;
if(Config -> EightyColumns)
LastColumn = 79;
else
LastColumn = (Window -> Width >> 3) - 1;
}
if(PrivateConfig . FontScale != SCALE_HALF && Config -> FontScale == SCALE_HALF)
{
if(Config -> EightyColumns)
LastColumn = 131;
else
LastColumn = (Window -> Width >> 2) - 1;
}
SetCursor();
}